home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / timeslaving / src / timeableid.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  1.3 KB  |  51 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. import quicktime.app.image.*;
  9. import quicktime.app.time.*;
  10. import quicktime.std.clocks.*;
  11. import java.awt.*;
  12. import quicktime.*;
  13.  
  14. class TimeableID extends QTImageDrawer implements Ticklish {
  15.     TimeableID (ScrollingText p, Dimension size) throws QTException {
  16.         super (p, size, kMultiFrame);
  17.         st = p;
  18.         setRedrawing(true);
  19.     }
  20.  
  21.     ScrollingText st;
  22.     Timer t;
  23.     
  24.     public void setTimer (Timer t) throws QTException {
  25.         this.t = t;
  26.     }    
  27.     
  28.     public boolean tickle (float er, int time) throws QTException {
  29.         return doTickle ();
  30.     }
  31.     
  32.     public void timeChanged (int time) throws QTException {
  33.         doTickle();
  34.     }
  35.     
  36. // Has an offset of 18 at the bottom and 22 at the top == 40        
  37.     private boolean doTickle () throws QTException {
  38.         st.oldy = st.y;
  39.         TimeBase tb = t.getTimeBase();
  40.         TimeBase master = tb.getMasterTimeBase();
  41.         if (master != null) {
  42.             int timeSpan = master.getStopTime(Ticklish.kScale) - master.getStartTime(Ticklish.kScale);
  43.             st.y = (int)((master.getTime(Ticklish.kScale) / (float)timeSpan) * (st.height - 40) + 22);
  44.         } else
  45.             st.y = (tb.getTime((st.height - 40))) % (st.height - 40) + 22;
  46.         
  47.         redraw(null);
  48.         return true;
  49.     }
  50. }
  51.